package com.fjl.boot;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

// 5. BeanDefinitionRegistryPostProcessor
@Component
class MyBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor {
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
        System.out.println(">> BeanDefinitionRegistryPostProcessor");
        registry.registerBeanDefinition("dynamicBean", BeanDefinitionBuilder.genericBeanDefinition(DynamicBean.class).getBeanDefinition());
    }
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        System.out.println(">> BeanDefinitionRegistryPostProcessor.postProcessBeanFactory");
    }
}